<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('审核')" />
    <th:block th:include="include :: datetimepicker-css" />
    </head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-agentDeductions-edit" th:object="${agentDeductions}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">审核类型：</label>
                <div class="col-sm-8">
                    <select id="auditStatus" name="auditStatus" class="form-control noselect2 selectpicker">
                        <option value="2">审核通过</option>
                        <option value="0">审核打回</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">服务商编号：</label>
                <div class="col-sm-8">
                    <input name="agentNum" th:field="*{agentNum}" id="xagentNum" class="form-control" type="text" disabled readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">服务商名称：</label>
                <div class="col-sm-8">
                    <input name="agentName" th:field="*{agentName}" onclick="selectAgent()"  class="form-control" id="xagentName" type="text" disabled required readonly>
                    <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">激活类型 ：</label>
                <div class="col-sm-8">
                    <select name="deductionType" onchange="terminalShow(this)" th:field="*{deductionType}" disabled class="form-control m-b">
                        <option value="2">伪激活</option>
                        <option value="1">机具扣款</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">机具类型：</label>
                <div class="col-sm-8">
                    <select id="posType" name="posType" class="form-control noselect2 selectpicker" th:field="*{posType}" disabled th:with="type=${@dict.getType('terminal_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div id="terminalShow" th:hidden="(*{deductionType} == 1)">
                <div class="form-group">
                    <label class="col-sm-3 control-label">sn：</label>
                    <div class="col-sm-8">
                        <input name="sn" id="sn" th:field="*{sn}" class="form-control" onclick="selectPos()" type="text" disabled required readonly>
                        <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">机具数量：</label>
                    <div class="col-sm-8">
                        <input name="posNumber" id="count" th:field="*{posNumber}" class="form-control" disabled type="text">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">扣款金额（元）：</label>
                <div class="col-sm-8">
                    <input name="deductionMoney" th:field="*{deductionMoney}" class="form-control" disabled type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">扣款比例（%）：</label>
                <div class="col-sm-8">
                    <input name="ratio" th:field="*{ratio}" class="form-control" disabled type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">扣款用途：</label>
                <div class="col-sm-8">
                    <input name="note" th:field="*{note}" class="form-control" disabled type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "finance/agentDeductions";
        $("#form-agentDeductions-edit").validate({
            focusCleanup: true
        });

        $("input[name='date']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/saveAudit", $('#form-agentDeductions-edit').serialize());
            }
        }

        function selectAgent() {
            var url =ctx + "terminal/record"+ "/selectAgentInfo";
            $.modal.open("选择服务商" , url, '700');
        }

        function selectPos() {
            if($("#xagentNum").val() == ""){
                $.modal.alertWarning("请先填写服务商！");
                return;
            }
            var url =prefix+ "/selectPosInfo?pos_type="+$("#posType").val()+"&agent_num="+$("#xagentNum").val()
            $.modal.open("选择sn机具" , url, '700');
        }

        function terminalShow(obj) {
            if(obj.value == 1){
                $("#terminalShow").hide();
            }else{
                $("#terminalShow").show();
            }
        }
    </script>
</body>
</html>